devtools::install_github("mplex/cedhar", subdir="pkg/sdam")
library(tidyverse)
library(sdam)
library(jsonlite)
library(getPass)
library(formatR)
library(leaflet)

Loading data

1. Load the credentials from external csv

mycred_secret<- readLines("~/mysecret.txt")

2. Make the request (you will be asked for password in a new pop-up window)

3. Make a list and tibble from the request function

list_json <- jsonlite::fromJSON(resp)
EDH_tibble = as_tibble(list_json)
head(EDH_tibble)
## # A tibble: 6 x 71
##   responsible_ind… type_of_inscrip… letter_size not_after literature work_status
##   <chr>            <chr>            <chr>       <chr>     <chr>      <chr>      
## 1 Feraudi          epitaph          3.2-2 cm    0130      AE 1983, … provisional
## 2 Feraudi          epitaph          4 cm        0200      AE 1983, … no image   
## 3 Feraudi          honorific inscr… 4.5-3 cm    0170      AE 1983, … provisional
## 4 Gräf             votive inscript… 2.5 cm      0200      AE 1983, … checked wi…
## 5 Feraudi          epitaph          <NA>        0200      AE 1983, … no image   
## 6 Gräf             epitaph          7-4 cm      0150      AE 1983, … checked wi…
## # … with 65 more variables: height <chr>, diplomatic_text <chr>, people <list>,
## #   depth <chr>, material <chr>, type_of_monument <chr>, province_label <chr>,
## #   width <chr>, transcription <chr>, country <chr>, uri <chr>,
## #   findspot_ancient <chr>, last_update <chr>, modern_region <chr>,
## #   findspot_modern <chr>, language <chr>, id <chr>, edh_geography_uri <chr>,
## #   commentary <chr>, trismegistos_uri <chr>, not_before <chr>, findspot <chr>,
## #   year_of_find <chr>, present_location <chr>, external_image_uris <list>,
## #   religion <chr>, fotos <list>, geography <chr>,
## #   social_economic_legal_history <chr>, military <chr>, coordinates <list>,
## #   idno_tm <chr>, placenames_refs <list>, text_edition <chr>,
## #   origdate_text <chr>, layout_execution <chr>, layout_execution_text <chr>,
## #   support_objecttype <chr>, support_objecttype_text <chr>,
## #   support_material <chr>, support_material_text <chr>,
## #   support_decoration <chr>, keywords_term <chr>, keywords_term_text <chr>,
## #   type_of_inscription_clean <chr>, type_of_inscription_certainty <chr>,
## #   height_cm <dbl>, width_cm <dbl>, depth_cm <dbl>, material_clean <chr>,
## #   type_of_monument_clean <chr>, type_of_monument_certainty <chr>,
## #   province_label_clean <chr>, province_label_certainty <chr>,
## #   country_clean <chr>, country_certainty <chr>, findspot_ancient_clean <chr>,
## #   findspot_ancient_certainty <chr>, modern_region_clean <chr>,
## #   modern_region_certainty <chr>, findspot_modern_clean <chr>,
## #   findspot_modern_certainty <chr>, findspot_clean <chr>,
## #   findspot_certainty <chr>, origdate_text_clean <chr>

Milestones as type of an inscription

unique(EDH_tibble$type_of_inscription_clean)
##  [1] "epitaph"                         "honorific inscription"          
##  [3] "votive inscription"              "defixio"                        
##  [5] "owner/artist inscription"        "mile-/leaguestone"              
##  [7] "acclamation"                     "boundary inscription"           
##  [9] "building/dedicatory inscription" "NULL"                           
## [11] "military diploma"                "identification inscription"     
## [13] "public legal inscription"        "private legal inscription"      
## [15] "label"                           "list"                           
## [17] "calendar"                        "seat inscription"               
## [19] "elogium"                         "assignation inscription"        
## [21] "prayer"                          "letter"                         
## [23] "adnuntiatio"
milestone_insc <- EDH_tibble %>% 
  filter(type_of_inscription_clean == "mile-/leaguestone")
nrow(milestone_insc)
## [1] 1730

Milestones as type of monument

unique(EDH_tibble$type_of_monument_clean)
##  [1] "tabula"                        "statue base"                  
##  [3] "altar"                         "stele"                        
##  [5] "tessera"                       "urn"                          
##  [7] "block"                         "bar"                          
##  [9] "mile-/leaguestone"             "NULL"                         
## [11] "herm"                          "instrumentum domesticum"      
## [13] "tile"                          "jewellery"                    
## [15] "cippus"                        "instrumentum militare"        
## [17] "paving stone"                  "sarcophagus"                  
## [19] "base"                          "architectural member"         
## [21] "cupa"                          "statue"                       
## [23] "slab"                          "instrumentum sacrum"          
## [25] "grave monument"                "sculpture"                    
## [27] "cliff"                         "relief"                       
## [29] "diptych"                       "bust"                         
## [31] "honorific/grave/votive column" "table"                        
## [33] "bench"                         "fountain"                     
## [35] "honorific/votive arch"         "weapon"                       
## [37] "shield"                        "olla"                         
## [39] "fortification"
milestone_monument <- EDH_tibble %>% 
  filter(EDH_tibble$type_of_monument_clean == "mile-/leaguestone")
nrow(milestone_monument)
## [1] 1735

Combine all milestones as type of monument and type of inscription

milestone_combined<- EDH_tibble %>% 
  filter(type_of_monument_clean == "mile-/leaguestone" | type_of_inscription_clean == "mile-/leaguestone")
nrow(milestone_combined)
## [1] 1761

Combine all milestones that have a word meilen- in commentary and are defined as milestones in type of monument and type of inscription

milestone_all <- EDH_tibble %>%  
  dplyr::filter(str_detect(commentary, "[M|m]eilen") | type_of_monument_clean == "mile-/leaguestone" | type_of_inscription_clean == "mile-/leaguestone" ) 
nrow(milestone_all)
## [1] 1770

How many % of the total number of EDH inscriptions represent milestones

nrow(milestone_all)/(nrow(EDH_tibble)/100)
## [1] 2.172419

Overview of all milestones

Type of inscription

milestone_all %>% 
  count(milestone_all$type_of_inscription_clean, sort = TRUE)
## # A tibble: 7 x 2
##   `milestone_all$type_of_inscription_clean`     n
##   <chr>                                     <int>
## 1 mile-/leaguestone                          1730
## 2 building/dedicatory inscription              22
## 3 honorific inscription                        11
## 4 list                                          3
## 5 NULL                                          2
## 6 epitaph                                       1
## 7 owner/artist inscription                      1

Type of monument

milestone_all %>% 
  count(milestone_all$type_of_monument_clean, sort = TRUE)
## # A tibble: 8 x 2
##   `milestone_all$type_of_monument_clean`     n
##   <chr>                                  <int>
## 1 mile-/leaguestone                       1735
## 2 tabula                                    21
## 3 NULL                                       6
## 4 architectural member                       4
## 5 block                                      1
## 6 cippus                                     1
## 7 slab                                       1
## 8 stele                                      1

Language

unnest_auto(milestone_all, language) %>% 
  count(language, sort=TRUE)
## Using `unnest_longer(language)`; no element has names
## # A tibble: 3 x 2
##   language        n
##   <chr>       <int>
## 1 Latin        1630
## 2 Greek-Latin   127
## 3 Greek          13

Material

milestone_all %>% 
  count(material_clean, sort=TRUE)
## # A tibble: 14 x 2
##    material_clean     n
##    <chr>          <int>
##  1 NULL             878
##  2 Limestone        335
##  3 Rock             238
##  4 Sandstone        181
##  5 Marble            84
##  6 Granit            20
##  7 Slate             11
##  8 Trachyte           6
##  9 Tuff               6
## 10 Quartz             4
## 11 Gneiss             3
## 12 Dolomit            2
## 13 Basalt             1
## 14 Metal              1

Dimensions

milestone_dims <- milestone_all %>% 
  dplyr::select(height_cm, width_cm, depth_cm)
milestone_dims <- as.data.frame(milestone_dims)

Basic statistical summary of Height in cm

summary(milestone_dims$height_cm)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     5.7    72.0   119.5   124.3   170.0   330.0     454

Basic statistical summary of Width in cm

summary(milestone_dims$width_cm)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    6.00   35.00   43.00   45.11   50.00  279.00     523

Basic statistical summary of Depth in cm

summary(milestone_dims$depth_cm)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    0.10   17.73   25.00   26.25   35.00   63.00    1622

Location

Ancient findspot - not cleaned

head(unique(milestone_all$findspot_ancient))
## [1] "Bracara Augusta - Lucus Augusti, inter"
## [2] "Bracara Augusta"                       
## [3] NA                                      
## [4] "Thibilis - Calama, inter"              
## [5] "Sebatum, bei"                          
## [6] "Aquae Flaviae"

Ancient findspot - cleaned

head(unique(milestone_all$findspot_ancient_clean))
## [1] "Bracara Augusta - Lucus Augusti" "Bracara Augusta"                
## [3] "NULL"                            "Thibilis - Calama"              
## [5] "Sebatum"                         "Aquae Flaviae"

Distribution by Roman provinces

milestone_all %>% 
  count(province_label_clean, sort =TRUE)
## # A tibble: 56 x 2
##    province_label_clean     n
##    <chr>                <int>
##  1 Hispania citerior      225
##  2 Dalmatia               138
##  3 Pannonia inferior      134
##  4 Britannia              128
##  5 Germania superior      127
##  6 Noricum                110
##  7 Moesia inferior         89
##  8 Pannonia superior       84
##  9 Africa Proconsularis    80
## 10 Bithynia et Pontus      67
## # … with 46 more rows
milestone_all %>% 
  count(province_label_clean, sort =TRUE) %>% 
  ggplot(aes(y=province_label_clean, x=n), size = n) +
  geom_point(color="red") +
  coord_fixed(ratio = 7/1) +
  labs(x = "Number of milestones", y = "Roman province", title = "Number of milestones per Roman Province", subtitle = "n = 1770" ) +
    theme_linedraw(base_size = 12)

Map of milestones (with available coordinates)

# selecting milestones with coordinates 
coords_milestone<- as.data.frame(cbind(id = milestone_all$id, 
                                       coordinates = milestone_all$coordinates, 
                                       findspot_ancient_clean = milestone_all$findspot_ancient_clean,
                                       type_of_inscription_clean = milestone_all$type_of_inscription_clean, 
                                       type_of_monument_clean = milestone_all$type_of_monument_clean, 
                                       not_before = milestone_all$not_before,
                                       not_after = milestone_all$not_after,
                                       commentary = milestone_all$commentary))

# milestones with no coordinates
coords_milestone_empty<- coords_milestone %>% 
  dplyr::filter(coordinates == "list()")

# milestones with coordinates
coords_milestone_full<- coords_milestone %>% 
  dplyr::filter(coordinates != "list()")

head(coords_milestone_full)
##         id      coordinates          findspot_ancient_clean
## 1 HD000024 -8.6346, 41.8676 Bracara Augusta - Lucus Augusti
## 2 HD000177 -8.5312, 41.6655 Bracara Augusta - Lucus Augusti
## 3 HD000180 -8.4200, 41.5503                 Bracara Augusta
## 4 HD000183 -8.5198, 41.4080                            NULL
## 5 HD000198 -7.6167, 43.2500                            NULL
## 6 HD000201 -8.5356, 41.3501                            NULL
##   type_of_inscription_clean type_of_monument_clean not_before not_after
## 1         mile-/leaguestone      mile-/leaguestone       0364      0375
## 2         mile-/leaguestone      mile-/leaguestone       0001      0300
## 3         mile-/leaguestone      mile-/leaguestone       0293      0395
## 4         mile-/leaguestone      mile-/leaguestone       0337      0340
## 5         mile-/leaguestone      mile-/leaguestone       0364      0375
## 6         mile-/leaguestone      mile-/leaguestone         NA        NA
##                                                                                                                                          commentary
## 1                                                                          (B): AE 1980: kleinere Abweichungen in Lesung, Ergänzung und Zeilenfall.
## 2             Meilenstein der via 19 des Itinerarium Antonini. Originalpublikation: Kaiser zwischen Tiberius und Vespasian. (B): Z.1 nicht gelesen.
## 3                                                                                         Y: Herrscher zwischen Constantius Chlorus und Theodosius.
## 4                                                                            Mit freundlichen Hinweis zum Fundort von António Faria (23. 2. 2000). 
## 5                                                                                                                   (B): kleinere Leseabweichungen.
## 6  Der Inschrifttext wurde in jüngerer Zeit offenbar nachgemeißelt. Ma[---]: Name des Herrschers nicht sicher zu bestimmen; vielleicht Ma[gnentio].
lat_long_milestone<- coords_milestone_full %>% 
  separate(col = coordinates, into = c("longitude", "latitude"), sep = ",")
## Warning: Expected 2 pieces. Missing pieces filled with `NA` in 102 rows [9, 33,
## 42, 66, 87, 101, 168, 248, 249, 316, 317, 366, 368, 387, 409, 459, 655, 657,
## 717, 723, ...].
lat_long_milestone$latitude <- as.numeric(str_replace(lat_long_milestone$latitude, pattern = "\\)", replacement=""))
lat_long_milestone$longitude <- as.numeric(str_replace(lat_long_milestone$longitude, pattern = "c\\(", replacement=""))
## Warning: NAs introduced by coercion
# how many milestones have coordinates
nrow(lat_long_milestone)
## [1] 1770

Map as dots

map_milestones_dot <-leaflet() %>%
  addProviderTiles("Stamen.Watercolor")%>% # Add CartoDB map tiles
  addCircles(lng = lat_long_milestone$longitude, 
             lat = lat_long_milestone$latitude, radius = 10, fill = TRUE, color= , fillColor = lat_long_milestone$type_of_monument_clean,
             popup = paste0("<b> InscriptionID: </b>", lat_long_milestone$id, 
                            "<br><b> Ancient findspot: </b>", lat_long_milestone$findspot_ancient,
                             "<br><b> Type of inscription: </b>", lat_long_milestone$type_of_inscription_clean,
                              "<br><b> Type of monument: </b>", lat_long_milestone$type_of_monument_clean,
                              "<br><b> Not before (date): </b>", lat_long_milestone$not_before,
                              "<br><b> Not after (date): </b>", lat_long_milestone$not_after,
                                "<br><b> Commentary: </b>", lat_long_milestone$commentary),
)
## Warning in validateCoords(lng, lat, funcName): Data contains 102 rows with
## either missing or invalid lat/lon values and will be ignored
map_milestones_dot

Map as clusters

map_milestones_cluster <-leaflet() %>%
  #addProviderTiles("Esri.WorldTopoMap", group = "Topo") %>%
  addProviderTiles("Esri.WorldImagery", group = "ESRI Aerial") %>%
  addMarkers(lng = lat_long_milestone$longitude, 
             lat = lat_long_milestone$latitude,
             popup = paste0("<b> InscriptionID: </b>", lat_long_milestone$id, 
                            "<br><b> Ancient findspot: </b>", lat_long_milestone$findspot_ancient,
                             "<br><b> Type of inscription: </b>", lat_long_milestone$type_of_inscription_clean,
                              "<br><b> Type of monument: </b>", lat_long_milestone$type_of_monument_clean,
                              "<br><b> Not before (date): </b>", lat_long_milestone$not_before,
                                "<br><b> Not after (date): </b>", lat_long_milestone$not_after,
                                "<br><b> Commentary: </b>", lat_long_milestone$commentary),
             
    clusterOptions = markerClusterOptions()
  )
## Warning in validateCoords(lng, lat, funcName): Data contains 102 rows with
## either missing or invalid lat/lon values and will be ignored
map_milestones_cluster

Map with Roman roads and provinces

library(rgdal)
## Loading required package: sp
## rgdal: version: 1.5-16, (SVN revision 1050)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 2.2.3, released 2017/11/20
## Path to GDAL shared files: /usr/share/gdal/2.2
## GDAL binary built with GEOS: TRUE 
## Loaded PROJ runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
## Path to PROJ shared files: (autodetected)
## WARNING: no proj_defs.dat in PROJ.4 shared files
## Linking to sp version:1.4-2
library(raster)
## 
## Attaching package: 'raster'
## The following object is masked from 'package:dplyr':
## 
##     select
## The following object is masked from 'package:tidyr':
## 
##     extract
library(sf)
## Linking to GEOS 3.6.2, GDAL 2.2.3, PROJ 4.9.3
library(sp)

source Roads: http://awmc.unc.edu/awmc/map_data/shapefiles/ba_roads/ source Roman provinces (AD 117): http://awmc.unc.edu/awmc/map_data/shapefiles/cultural_data/political_shading/roman_empire_ad_117/shape/

setwd("~/Github/epigraphic_roads")
dir.create("../data/ba_roads")
## Warning in dir.create("../data/ba_roads"): '../data/ba_roads' already exists
unzip("../data/ba_roads.zip", exdir = "../data/ba_roads/")
## Warning in unzip("../data/ba_roads.zip", exdir = "../data/ba_roads/"): error 1
## in extracting from zip file
dir.create("../data/roman_empire_200_ad_provinces")
## Warning in dir.create("../data/roman_empire_200_ad_provinces"): '../data/
## roman_empire_200_ad_provinces' already exists
unzip("../data/roman_empire_ad_200_provinces.zip", exdir = "../data/roman_empire_200_ad_provinces")
## Warning in unzip("../data/roman_empire_ad_200_provinces.zip", exdir = "../data/
## roman_empire_200_ad_provinces"): error 1 in extracting from zip file
roads <- st_read("../data/ba_roads/ba_roads.shp")
## Reading layer `ba_roads' from data source `/home/petra/Github/epigraphic_roads/data/ba_roads/ba_roads.shp' using driver `ESRI Shapefile'
## replacing null geometries with empty geometries
## Simple feature collection with 2739 features and 26 fields (with 1 geometry empty)
## geometry type:  LINESTRING
## dimension:      XY
## bbox:           xmin: -9.29586 ymin: 23.90006 xmax: 52.88473 ymax: 56.52055
## CRS:            4326
provinces200 <- st_read("../data/roman_empire_200_ad_provinces/roman_empire_ad_200_provinces.shp")
## Reading layer `roman_empire_ad_200_provinces' from data source `/home/petra/Github/epigraphic_roads/data/roman_empire_200_ad_provinces/roman_empire_ad_200_provinces.shp' using driver `ESRI Shapefile'
## replacing null geometries with empty geometries
## Simple feature collection with 81 features and 11 fields (with 1 geometry empty)
## geometry type:  LINESTRING
## dimension:      XY
## bbox:           xmin: NA ymin: NA xmax: NA ymax: NA
## CRS:            4326
orbis <- readLines("https://raw.githubusercontent.com/emeeks/orbis_v2/master/base_routes.geojson") %>% paste(collapse = "\n") %>% 
  fromJSON(simplifyVector = FALSE)
map_milestones_provinces<- leaflet() %>%
 addProviderTiles("Esri.WorldTopoMap", group = "Topo") %>%
 addProviderTiles("Esri.WorldImagery", group = "ESRI Aerial") %>%
 addPolylines(data = provinces200, color = "red", weight = 2, opacity = 0.8) %>% 
  addCircles(lng = lat_long_milestone$longitude, 
             lat = lat_long_milestone$latitude, radius = 10, fill = TRUE, color = "yellow" , fillColor = "red",
             popup = paste0("<b> InscriptionID: </b>", lat_long_milestone$id, 
                            "<br><b> Ancient findspot: </b>", lat_long_milestone$findspot_ancient,
                             "<br><b> Type of inscription: </b>", lat_long_milestone$type_of_inscription_clean,
                              "<br><b> Type of monument: </b>", lat_long_milestone$type_of_monument_clean,
                              "<br><b> Not before (date): </b>", lat_long_milestone$not_before,
                              "<br><b> Not after (date): </b>", lat_long_milestone$not_after,
                                "<br><b> Commentary: </b>", lat_long_milestone$commentary),
)
## Warning in validateCoords(lng, lat, funcName): Data contains 102 rows with
## either missing or invalid lat/lon values and will be ignored
map_milestones_provinces
map_milestones_roads<- leaflet() %>%
 addProviderTiles("Esri.WorldTopoMap", group = "Topo") %>%
 addProviderTiles("Esri.WorldImagery", group = "ESRI Aerial") %>%
 addPolylines(data = roads, color = "purple", weight = 2, opacity = 0.7) %>% 
  addCircles(lng = lat_long_milestone$longitude, 
             lat = lat_long_milestone$latitude, opacity = 1, radius = 10, fill = TRUE, color = "yellow" , fillColor = "red",
             popup = paste0("<b> InscriptionID: </b>", lat_long_milestone$id, 
                            "<br><b> Ancient findspot: </b>", lat_long_milestone$findspot_ancient,
                             "<br><b> Type of inscription: </b>", lat_long_milestone$type_of_inscription_clean,
                              "<br><b> Type of monument: </b>", lat_long_milestone$type_of_monument_clean,
                              "<br><b> Not before (date): </b>", lat_long_milestone$not_before,
                              "<br><b> Not after (date): </b>", lat_long_milestone$not_after,
                                "<br><b> Commentary: </b>", lat_long_milestone$commentary),)
## Warning in validateCoords(lng, lat, funcName): Data contains 102 rows with
## either missing or invalid lat/lon values and will be ignored
map_milestones_roads

Location of milestones compared with all inscriptions

# inscriptions with coordinates

lat_long_EDH <- EDH_tibble %>%  
  separate(col = coordinates, into = c("longitude", "latitude"), sep = ",")
## Warning: Expected 2 pieces. Missing pieces filled with `NA` in 2464 rows [20,
## 34, 64, 71, 94, 149, 212, 221, 296, 311, 356, 382, 388, 390, 405, 406, 409, 412,
## 418, 421, ...].
lat_long_EDH
## # A tibble: 81,476 x 72
##    responsible_ind… type_of_inscrip… letter_size not_after literature
##    <chr>            <chr>            <chr>       <chr>     <chr>     
##  1 Feraudi          epitaph          3.2-2 cm    0130      AE 1983, …
##  2 Feraudi          epitaph          4 cm        0200      AE 1983, …
##  3 Feraudi          honorific inscr… 4.5-3 cm    0170      AE 1983, …
##  4 Gräf             votive inscript… 2.5 cm      0200      AE 1983, …
##  5 Feraudi          epitaph          <NA>        0200      AE 1983, …
##  6 Gräf             epitaph          7-4 cm      0150      AE 1983, …
##  7 Feraudi          epitaph          9 cm        -0051     AE 1983, …
##  8 Feraudi          epitaph          4-2 cm      0200      AE 1983, …
##  9 Cowey            defixio          <NA>        0300      AE 1983, …
## 10 Gräf             epitaph          4.2-2.5 cm  0200      AE 1983, …
## # … with 81,466 more rows, and 67 more variables: work_status <chr>,
## #   height <chr>, diplomatic_text <chr>, people <list>, depth <chr>,
## #   material <chr>, type_of_monument <chr>, province_label <chr>, width <chr>,
## #   transcription <chr>, country <chr>, uri <chr>, findspot_ancient <chr>,
## #   last_update <chr>, modern_region <chr>, findspot_modern <chr>,
## #   language <chr>, id <chr>, edh_geography_uri <chr>, commentary <chr>,
## #   trismegistos_uri <chr>, not_before <chr>, findspot <chr>,
## #   year_of_find <chr>, present_location <chr>, external_image_uris <list>,
## #   religion <chr>, fotos <list>, geography <chr>,
## #   social_economic_legal_history <chr>, military <chr>, longitude <chr>,
## #   latitude <chr>, idno_tm <chr>, placenames_refs <list>, text_edition <chr>,
## #   origdate_text <chr>, layout_execution <chr>, layout_execution_text <chr>,
## #   support_objecttype <chr>, support_objecttype_text <chr>,
## #   support_material <chr>, support_material_text <chr>,
## #   support_decoration <chr>, keywords_term <chr>, keywords_term_text <chr>,
## #   type_of_inscription_clean <chr>, type_of_inscription_certainty <chr>,
## #   height_cm <dbl>, width_cm <dbl>, depth_cm <dbl>, material_clean <chr>,
## #   type_of_monument_clean <chr>, type_of_monument_certainty <chr>,
## #   province_label_clean <chr>, province_label_certainty <chr>,
## #   country_clean <chr>, country_certainty <chr>, findspot_ancient_clean <chr>,
## #   findspot_ancient_certainty <chr>, modern_region_clean <chr>,
## #   modern_region_certainty <chr>, findspot_modern_clean <chr>,
## #   findspot_modern_certainty <chr>, findspot_clean <chr>,
## #   findspot_certainty <chr>, origdate_text_clean <chr>
lat_long_EDH$latitude <- as.numeric(str_replace(lat_long_EDH$latitude, pattern = "\\)", replacement=""))
lat_long_EDH$longitude <- as.numeric(str_replace(lat_long_EDH$longitude, pattern = "c\\(", replacement=""))
## Warning: NAs introduced by coercion
# how many inscriptions have coordinates
nrow(lat_long_EDH)
## [1] 81476
# how many % of the total represent milestones with coordinates
nrow(lat_long_milestone)/(nrow(lat_long_EDH)/100)
## [1] 2.172419
map_milestones_compared<- leaflet() %>%
addProviderTiles("Stamen.TerrainBackground")%>% # Add CartoDB map tiles
# addProviderTiles("Esri.WorldImagery", group = "ESRI Aerial") %>%
# addPolylines(data = roads, color = "purple", weight = 2, opacity = 0.7) %>% 
  setView( lng = 22.326743, lat = 46.897122, zoom = 4 ) %>%
  setMaxBounds(lat1=43.633977, lng1 =-11.227926 , lat2=35.133882 , lng2=50.882336) %>% 
  addCircles(lng = lat_long_EDH$longitude, 
             lat = lat_long_EDH$latitude, opacity = 0.5, radius = 10, fill = TRUE, color = "black" , fillColor = "white",) %>% 
  addCircles(lng = lat_long_milestone$longitude, 
             lat = lat_long_milestone$latitude, opacity = 0.5, radius = 10, fill = TRUE, color = "yellow" , fillColor = "",
             popup = paste0("<b> InscriptionID: </b>", lat_long_milestone$id, 
                            "<br><b> Ancient findspot: </b>", lat_long_milestone$findspot_ancient,
                             "<br><b> Type of inscription: </b>", lat_long_milestone$type_of_inscription_clean,
                              "<br><b> Type of monument: </b>", lat_long_milestone$type_of_monument_clean,
                              "<br><b> Not before (date): </b>", lat_long_milestone$not_before,
                              "<br><b> Not after (date): </b>", lat_long_milestone$not_after,
                                "<br><b> Commentary: </b>", lat_long_milestone$commentary),
             ) %>% 
addLegend(position = "topright",
  colors = c("Yellow", "Black"),
  labels = c("Milestones", "Other inscriptions"), opacity = 1,
  title = "Milestones vs other inscriptions (EDH)"
)
## Warning in validateCoords(lng, lat, funcName): Data contains 2464 rows with
## either missing or invalid lat/lon values and will be ignored
## Warning in validateCoords(lng, lat, funcName): Data contains 102 rows with
## either missing or invalid lat/lon values and will be ignored
map_milestones_compared

Dates

#dates<- milestone_all %>% 
  #select(not_before, not_after, origdate_text, origdate_attrs) 
#dates_flat <- flatten(dates)
#dates_flat$not_before <- as.numeric(dates_flat$not_before)
#dates_flat$not_after <- as.numeric(dates_flat$not_after)
#summary(dates_flat$not_before)
#plot(dates_flat$not_before)
#summary(dates_flat$not_after)
#plot(dates_flat$not_after)

Temporal distribution of ‘not_before’ years of milestones

#plot(table(dates_flat$not_before), ylab= "Number of inscriptions", xlab="'Not before' YEAR")

Combining dates and provinces - unfinished

#milestones_flat <- flatten(milestone_all)
#milestones_flat
# remove any traces of the secret password from the document
remove(mycred_secret)